package com.winsdom.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.winsdom.anno.Authentication;
import com.winsdom.dto.FormulaDTO;
import com.winsdom.enums.AuthenticationType;
import com.winsdom.result.Result;
import com.winsdom.service.IFormulaService;
import com.winsdom.vo.FormulaVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 公式表 前端控制器
 * </p>
 *
 * @author
 * @since 2025-05-23
 */
@RestController
@RequestMapping("/formula")
@Api(tags = "公式管理")
@Authentication(AuthenticationType.FORMULA_MANAGEMENT)
@Slf4j
public class FormulaController {
    @Autowired
    IFormulaService formulaService;

    @ApiOperation("查询公式列表")
    @GetMapping("/list")
    public Result list(
            @RequestParam(value = "公式类型", required = false) Long type,
            @Parameter(description = "页码") @RequestParam(defaultValue = "1") Integer pageNum,
            @Parameter(description = "页面大小") @RequestParam(defaultValue = "10") Integer pageSize) {
        log.info("type:{}",type);
        FormulaDTO formulaDTO = new FormulaDTO();
        formulaDTO.setType(type);
        formulaDTO.setPageNum(pageNum);
        formulaDTO.setPageSize(pageSize);
        IPage<FormulaVO> list = formulaService.list(formulaDTO);
        return Result.success(list);
    }
}

